package codemapping

import (
	nw "lnzw/engine/net/work"

	"google.golang.org/protobuf/proto"
)

type Mapping struct {
	Code int32
	Req  proto.Message
	Res  proto.Message
	Work nw.IProtobufNetWork[proto.Message, proto.Message]
}

var mappingCodes = map[int32]Mapping{}

func Register(code int32, req proto.Message, res proto.Message, work nw.IProtobufNetWork[proto.Message, proto.Message]) {
	mappingCodes[code] = Mapping{
		Req:  req,
		Res:  res,
		Work: work,
	}
}

func GetMapping(code int32) (bool, Mapping) {
	mapping, ok := mappingCodes[code]
	return ok, mapping
}
